package cn.samir.sudoku.app;

import java.io.File;

import com.nostra13.universalimageloader.cache.disc.impl.UnlimitedDiscCache;
import com.nostra13.universalimageloader.cache.disc.naming.HashCodeFileNameGenerator;
import com.nostra13.universalimageloader.core.DisplayImageOptions;
import com.nostra13.universalimageloader.core.ImageLoader;
import com.nostra13.universalimageloader.core.ImageLoaderConfiguration;
import com.nostra13.universalimageloader.core.download.URLConnectionImageDownloader;

import cn.samir.sudoku.keys.Conf;
import android.app.Application;

public class ApiClient extends Application {

	@Override
	public void onCreate() {

		super.onCreate();

		File file = new File(Conf.file_root);
		if (!file.exists()) {
			file.mkdirs();
		}

		File cacheDir = getCacheDir();
		ImageLoaderConfiguration config = new ImageLoaderConfiguration.Builder(
				getApplicationContext())
				.memoryCacheExtraOptions(480, 800)
				.threadPoolSize(3)
				.threadPriority(Thread.NORM_PRIORITY - 1)
				.denyCacheImageMultipleSizesInMemory()
				.discCache(new UnlimitedDiscCache(cacheDir))
				// default
				.discCacheSize(50 * 1024 * 1024)
				// 缓冲大小
				.discCacheFileCount(100)
				// 缓冲文件数目
				.discCacheFileNameGenerator(new HashCodeFileNameGenerator())
				// default
				.imageDownloader(
						new URLConnectionImageDownloader(5 * 1000, 20 * 1000))
				.defaultDisplayImageOptions(DisplayImageOptions.createSimple())
				.enableLogging().build();
		ImageLoader imageLoader = ImageLoader.getInstance();
		imageLoader.init(config);

	}
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
}
